package com.yanqu.road.server.cmd.activity.chuhan.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChuHanProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.tongbing.ChuHanModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;


@Cmd(code = GameProtocol.S_CROSS_CHUHAN_RED_PACKET_BOX_VALUE_SYNC, desc = "")
public class ChuHanRedPacketBoxValueSyncCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        ChuHanProto.CrossChuHanRedPacketBoxValueSyncMsg syncMsg = ChuHanProto.CrossChuHanRedPacketBoxValueSyncMsg.parseFrom(packet.getBytes());
        int activityId = syncMsg.getActivityId();
        for(long userId : syncMsg.getUserIdsList()){
            GamePlayer player = GamePlayerMgr.getOnlinePlayer(userId);
            if(player != null){
                player.getModule(ChuHanModule.class).notifyRedPackValue(activityId,syncMsg.getValue());
            }
        }
    }

}
